#ifndef LINKEDLIST_H
#define LINKEDLIST_H

#include <iostream>

// Linked list class
// Works with all data types
// You're welcome -_-

template <class T>
class LinkedList
{
	private:
		// Node structure
		struct Node{
			T t;
			Node *next;
		}*head;
	public:
		LinkedList(){ head = NULL;}

		~LinkedList() {
			Node *a = head; // Accessor

			while (!head){
				a = head->next;
				delete head;
				head = a;
			}
		}
//####################################################
		// Add a node
		void Add(T item){
			Node *a = head; // Accessor node

			// Create the head node and/or
			// add the new item to the list
			if (!head){
				head = new Node();
				head.t = item;
				head.next = NULL;
			} else{
				while (a.next != NULL){
					a = a.next;
				}

				// Node to be added
				Node *b = new Node();
				b.next = NULL;
				b.t = item;
				a.next = b;
			}
		}

		// Delete a certain node from the list
		void Delete(T item){
			Node *a, *b; // Accessors
   			a = head;

			// Delete if the head is the node
   			if( a.t == item )
   			{
	        	head = a->next;
    	 		delete a;
      			return;
   			}

			// Delete otherwise
   			b = a;
   			while( a!=NULL )
   			{
        		if( a.t == item )
      			{
           			b->next = a->next;
         			delete a;
         			return;
      			}

      			b = a;
      			a = a->next;
   			}
		}

		T &At(int i){
			Node *a = head; // Accessor

			for (int n = 0; n < i; n++){
				a = a->next;
			}

			return a->t;
		}
//#######################################################
		// Get the total amount of nodes in the linked list
		int totalNodes(){
			int x = 0;

			Node *a = head; // Temporary accessor

			while (a){
				x++;
				a = a.next;
			}

			return x;
		}
};

#endif // LINKEDLIST_H

sprite.SetImg(GetImageManager().Load("img.png";));
sprite.SetPos(x, y);
sprite.SetX( x );
sprite.SetY( y );